package tdt4240.iddqd.camera;

import org.anddev.andengine.engine.camera.hud.HUD;
import org.anddev.andengine.entity.primitive.Rectangle;
import org.anddev.andengine.entity.text.ChangeableText;
import org.anddev.andengine.input.touch.TouchEvent;

import tdt4240.iddqd.GameActivity;
import tdt4240.iddqd.GameScene;

public class GameHud extends HUD {

	private Rectangle attackButton;
	private ChangeableText healthDisplay;
	private int CAMERA_WIDTH = GameActivity.CAMERA_WIDTH;
	private int CAMERA_HEIGHT = GameActivity.CAMERA_HEIGHT;

	public GameHud(){
		attackButton = new Rectangle(CAMERA_WIDTH/2, 0, CAMERA_WIDTH/2, CAMERA_HEIGHT){
			@Override
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
					float pTouchAreaLocalX, float pTouchAreaLocalY) {
				if (pSceneTouchEvent.isActionUp()) 
					GameScene.scene.playerAttacks();
				return true;
			}
		};
		attackButton.setAlpha(0);
		healthDisplay = new ChangeableText(50, 50, GameActivity.mFont, "100");
		attachChild(healthDisplay);
		registerTouchArea(attackButton);
		attachChild(attackButton);
	}

	/**
	 * Update health display
	 * @param health Remaining health
	 */
	public void updateHealth(int health){
		healthDisplay.setText(health+"");
	}

}
